package org.csu.code.api.controller;

import org.apache.catalina.Manager;
import org.csu.code.api.common.CommonResponse;
import org.csu.code.api.entity.*;
import org.csu.code.api.service.CatalogService;
import org.csu.code.api.service.ManagerService;
import org.csu.code.api.service.OrderService;
import org.csu.code.api.vo.AccountVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/manage/")
public class ManagerController {

    @Autowired
    ManagerService managerService;

    //上架
    @GetMapping("enableItem/{id}")
    @ResponseBody
    public CommonResponse<String> enableItem(@PathVariable("id") String itemId){
        return managerService.enableItem(itemId);
    }

    @PutMapping("editItem")
    @ResponseBody
    public CommonResponse<Item> editItem(@RequestBody Item item){
        return managerService.editItem(item);
    }

    //更新信息
    @PutMapping("account")
    @ResponseBody
    public CommonResponse<String> updateAccount(@RequestBody AccountVO accountVO){
        return managerService.updateAccount(accountVO);
    }

    }
